<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery/1.12.3/jquery.js"></script>
<script type="text/javascript">
function get(url, callback){
	var oReq = new XMLHttpRequest()
	oReq.onload = function(){
		callback(oReq.responseText)
	}
	oReq.open('get', url, true)
	oReq.send()
}

function post(url, data, callback){
	var oReq = new XMLHttpRequest()
	oReq.onload = function(){
		callback(oReq.responseText)
	}
	oReq.open('post', url, true)
	oReq.send(data)
}
var postData = {
	"id": 3,
	"title": "我是新加入的新闻",
	"date": "2016-08-12",
	"likes": 0,
	"views": 0
}
// post('http://localhost:3003/news', JSON.stringify(postData), function(res){
// 	console.log(res)
// })

// get('http://localhost:3003/news/1', function(data){
// 	console.log(data)
// })
// $.ajax({
// 	type:'post',
// 	url:'http://localhost:3003/news',
// 	// dataType:'json',
// 	data:postData,
// 	success:function(res){
// 		console.log(res)
// 	}
// })

$.ajax({
    type: 'post',
    url: 'http://localhost:3003/news',
    data: {
      "id": 3,
      "title": "我是新加入的新闻",
      "date": "2016-08-12",
      "likes": 0,
      "views": 0
    }
  }
)
</script>
</body>
</html>